package com.quick.api;

import com.quick.domain.WeatherResponse;
import com.quick.service.CutService;
import com.quick.service.WeatherDataService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 功能描述 TODO
 *
 * @Created Time 2017/9/6
 * @Edited Time 2017/9/6
 * @Created by wangxin43
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {
    @Autowired
    private WeatherDataService weatherDataService;

    @Resource
    private CutService cutService;


    @ApiOperation(value="根据id获取城市天气", notes="根据id获取城市天气")
    @ApiImplicitParam(name = "cityId", value = "城市id", required = true, dataType = "String",paramType = "path")
    @GetMapping("/cityId/{cityId}")
    public WeatherResponse getReportByCityId(@PathVariable("cityId") String cityId) {
        return weatherDataService.getDataByCityId(cityId);
    }


    @ApiOperation(value="根据名称获取城市天气", notes="根据名称获取城市天气")
    @ApiImplicitParam(name = "cityName", value = "cityName", required = true, dataType = "StringString",paramType = "path")
    @GetMapping("/cityName/{cityName}")
    public WeatherResponse getReportByCityName(@PathVariable("cityName") String cityName) {
        return weatherDataService.getDataByCityName(cityName);
    }

    @RequestMapping("/cut")
    public String cut(String word){
        return cutService.cut(word);
    }
}
